﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace WebTools
{
    public partial class SqlFieldsCompare : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string strText = txtSource.Text.Replace("'", "").Replace("[", "").Replace("]", "");
            string strFields = strText.Substring(strText.IndexOf("(") + 1, strText.IndexOf(")") - strText.IndexOf("(") - 1);
            string strValues = strText.Substring(strText.LastIndexOf("(") + 1, strText.LastIndexOf(")") - strText.LastIndexOf("(") - 1);

            StringBuilder sb = new StringBuilder();
            GetStringSplit(strFields, sb);
            txbFields.Value = sb.ToString();

            sb = new StringBuilder();
            GetStringSplit(strValues, sb);
            txbvalue.Text = sb.ToString();
        }

        private static void GetStringSplit(string strFields, StringBuilder sb)
        {
            string[] strSource = strFields.Split(',');
            for (int i = 0; i < strSource.Length; i++)
            {
                //if (strSource[i].Trim().Length > 0)
                //{
                sb.AppendLine(strSource[i].Trim());
                //}
            }
        }
    }
}